<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
  <div id="app">
    <!-- 表达式 -->
    {{ message }}
    <hr>
    {{user.username}}
  </div>

  <script>

    let user = { username: 'admin', age: 20 }

    //冻结
    Object.freeze(user);

    var vm = new Vue({
      //选项
      el: "#app",
      //响应式的数据
      data: {
        message: "helloworld",
        user
      }
    })

    vm.$watch('message', function (newval, oldval) {
      console.log(newval, oldval)
    })

  </script>

</body>

</html>